/*
 * The FUJABA ToolSuite for Eclipse project:
 *
 *   FUJABA is the acronym for 'From Uml to Java And Back Again'
 *   and originally aims to provide an environment for round-trip
 *   engineering using UML as visual programming language. During
 *   the last years, the environment has become a base for several
 *   research activities, e.g. distributed software, database
 *   systems, modelling mechanical and electrical systems and
 *   their simulation. Thus, the environment has become a project,
 *   where this source code is part of. Further details are avail-
 *   able via http://www.fujaba.de
 *
 *      Copyright (C) Fujaba Development Group
 *
 *   This library is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Lesser General Public
 *   License as published by the Free Software Foundation; either
 *   version 2.1 of the License, or (at your option) any later version.
 *
 *   You should have received a copy of the GNU Lesser General Public
 *   License along with this library; if not, write to the Free
 *   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *   MA 02111-1307, USA or download the license under
 *   http://www.gnu.org/copyleft/lesser.html
 *
 * WARRANTY:
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *   GNU Lesser General Public License for more details.
 *
 * Contact address:
 *
 *   Fujaba Management Board
 *   Software Engineering Group
 *   University of Paderborn
 *   Warburgerstr. 100
 *   D-33098 Paderborn
 *   Germany
 *
 *   URL  : http://www.fujaba.de
 *   email: info@fujaba.de
 *
 */
package org.fujaba.sdm.ui.figures;

import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Rectangle;
import org.fujaba.commons.Commons4EclipseFonts;
import org.fujaba.commons.figures.LabelFigure;



/**
 * @author    Dietrich Travkin (travkin)
 * @author    Last editor: $Author: travkin $
 * @version   $Revision: 976 $ $Date: 2006-04-11 19:07:29 +0200 (Di, 11 Apr 2006) $
 */
public class UMLStatementActivityFigure extends AbstractUMLActivityFigure
{
   /**
    * No comment provided by developer, please add a comment to improve documentation.
    */
   private LabelFigure statement;


   /**
    *Constructor for class UMLStatementActivityFigure
    *
    * @param statement  No description provided
    */
   public UMLStatementActivityFigure (String statement)
   {
      BorderLayout layout = new BorderLayout();
      this.getContentsPane().setLayoutManager (layout);
      this.statement = new LabelFigure (statement, Commons4EclipseFonts.getFont (Commons4EclipseFonts.FONT_DEFAULT_NORMAL));
      this.addChildFigure (this.statement, BorderLayout.CENTER);
   }


   /**
    * Access method for a To N-association.
    *
    * @param figure  The object added.
    */
   public void addChildFigure (IFigure figure)
   {
      Rectangle bounds = figure.getBounds();
      this.addChildFigure (figure, new Rectangle (bounds.getLocation(), figure.getPreferredSize()));
   }


   /**
    * Access method for a To N-association.
    *
    * @param figure      The object added.
    * @param constraint  The object added.
    */
   public void addChildFigure (IFigure figure, Object constraint)
   {
      IFigure contentsPane = this.getContentsPane();
      contentsPane.add (figure, constraint);
      //contentsPane.getLayoutManager().invalidate();
      //contentsPane.setSize (contentsPane.getLayoutManager().getPreferredSize (contentsPane, -1, -1));
      //this.getContentsPane().setSize (this.getContentsPane().getPreferredSize());
      this.getLayoutManager().invalidate();
      this.getLayoutManager().layout (this);
      //this.setSize (this.getLayoutManager().getPreferredSize (this, -1, -1));
      //this.repaint();
   }


   /**
    * Get the statement attribute of the UMLStatementActivityFigure object
    *
    * @return   The statement value
    */
   public String getStatement()
   {
      return this.statement.getName();
   }


   /**
    * Sets the statement attribute of the UMLStatementActivityFigure object
    *
    * @param statement  The new statement value
    */
   public void setStatement (String statement)
   {
      this.statement.setName (statement);
   }
}

/*
 * $Log$
 * Revision 1.4  2006/04/11 17:07:05  travkin
 * Changed some javadoc comments.
 *
 */
